package com.maybach.component.city.domain;

/**
 * Created by well on 15/3/26.
 */
public class City {

    private Integer cityId;
    private String name;
    private Integer proID;
    private int citySort;
    private String shortName;

    public Integer getCityId() {
        return cityId;
    }

    public void setCityId(Integer cityId) {
        this.cityId = cityId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
        setShortName(name);
    }

    public Integer getProID() {
        return proID;
    }

    public void setProID(Integer proID) {
        this.proID = proID;
    }

    public int getCitySort() {
        return citySort;
    }

    public void setCitySort(int citySort) {
        this.citySort = citySort;
    }

    public void setShortName(String name) {
        if(name==null)
            return;
        int length = name.length();
        if(length==3&&name.indexOf("市")==length-1){
            this.shortName = name.substring(0,2);
        }else if(length==3){
            this.shortName = name.substring(0,3);
        }else if(length==4&&name.indexOf("市")==length-1){
            this.shortName = name.substring(0,3);
        }else if(length==5&&name.indexOf("市")==length-1){
            this.shortName = name.substring(0,4);
        }else if(length>4){
            this.shortName = name.substring(0, 3) + "...";
        }else{
            this.shortName = name;
        }
    }

    public String getShortName() {
        return shortName;
    }
}
